import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';

const initState = {
    employeeList: [],
};

// 把初始state给reducer的默认
function reducer (state = initState, action) {
    const newState = { ...state };
    switch (action.type) {
        case 'UPDATE_EMPLOYEE_LIST':
            newState.employeeList = action.value;
            break;
    
        default:
            break;
    }
    return newState;
}

// 生成一个中间件（小插件）（外挂）
const middlewares = applyMiddleware(thunk);

// 挂了外挂之后  store可以发异步了
export default createStore( reducer, middlewares );
